//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//********************************************************* 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.TridentWordAddIn.Common;

namespace Microsoft.TridentWordAddIn.Presentation
{
    internal partial class WebServiceAccountInformation : UserControl
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="WebServiceAccountInformation"/> class.
        /// </summary>
        public WebServiceAccountInformation()
        {
            InitializeComponent();
            this.ctrAccessKey.OnValidation += new EventHandler<ConnectionValidateEventArgs>(ctrAccessKey_OnValidation);
        }

        #endregion

        /// <summary>
        /// Occurs when [on validation].
        /// </summary>
        public event EventHandler<ConnectionValidateEventArgs> OnValidation;

        #region Properties

        /// <summary>
        /// Gets or sets the access key id.
        /// </summary>
        /// <value>The access key id.</value>
        public string AccessKeyId
        {
            get
            {
                return this.ctrAccessKey.AccessKeyID;
            }
            set
            {
                this.ctrAccessKey.AccessKeyID = value;
            }
        }

        /// <summary>
        /// Gets or sets the secret access key.
        /// </summary>
        /// <value>The secret access key.</value>
        public string SecretAccessKey
        {
            get
            {
                return this.ctrAccessKey.SecretAccessKey;
            }
            set
            {
                this.ctrAccessKey.SecretAccessKey = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is public object.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is public object; otherwise, <c>false</c>.
        /// </value>
        public bool IsPublicObject
        {
            get
            {
                return this.cbxAnonymous.Checked;
            }
            set
            {
                this.cbxAnonymous.Checked = value;
            }
        }

        #endregion

        #region Event

        /// <summary>
        /// Handles the OnValidation event of the accessKeyInfo control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.TridentWordAddIn.Common.ConnectionValidateEventArgs"/> instance containing the event data.</param>
        private void ctrAccessKey_OnValidation(object sender, ConnectionValidateEventArgs e)
        {
            if (this.OnValidation != null)
            {
                this.OnValidation(sender, e);
            }
        }

        #endregion

        /// <summary>
        /// Determines whether this instance is valid.
        /// </summary>
        public ValidationResult IsValid()
        {
            return this.ctrAccessKey.IsValid();
        }
    }
}
